using UnityEngine;
using System.Collections;

public class MenuScript : MonoBehaviour {
	private bool GamePaused = false;
	public GameObject VersionText;
	private Rect rctWindow = new Rect((Screen.width/2)-200,(Screen.height/2)-100,400,300);
	private bool MenuWindowActive = false;
	
	
	// Use this for initialization
	void Start () {
	
	}
	
	void OnGUI () {
		GUI.color = new Color(1f,0.1f,0.1f,1f);
		if(GamePaused){
			if(GUI.Button(new Rect(10,15,60,20),"Menu")){
				ToggleMenuWindow();
			}
			if(MenuWindowActive){
				rctWindow = GUI.Window(10, rctWindow, MenuWindow, "Menu", GUI.skin.GetStyle("window"));
				GUI.FocusWindow(10);
			}
		}
	}
	
	void MenuWindow(int windowID){
		GUILayout.BeginVertical();
		if(Network.isServer){
			GUILayout.Label("Serveur : "+Network.player.ipAddress+":"+Network.player.port.ToString());
		}
		if(Network.isClient){
			GUILayout.Label("Serveur : "+Network.player.externalIP+":"+Network.player.externalPort.ToString());
		}
		if(GUILayout.Button("Quitter la partie",GUILayout.ExpandWidth(false))){
			Application.Quit();
		}
		GUILayout.EndVertical();
	}
	
	// Update is called once per frame
	void Update () {
		if(GamePaused){
			VersionText.active = true;
		}
		else{
			VersionText.active = false;
		}
	}
	
	void TogglePause(){
		GamePaused = !GamePaused;
	}
	
	void ToggleMenuWindow(){
		MenuWindowActive = !MenuWindowActive;
	}
}
